﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Lottery.MediaData.UI.Control {
    /// <summary>
    /// 数据大中小 输入控件
    /// </summary>
    public partial class DZXInput : UserControl {
        public DZXInput() {
            InitializeComponent();

            m_controls.Add(d1);
            m_controls.Add(d2);
            m_controls.Add(d3);
            m_controls.Add(d4);
            m_controls.Add(d5);
            m_controls.Add(d6);
            m_controls.Add(d7);
            m_controls.Add(d8);
            m_controls.Add(d9);
            m_controls.Add(d10);
            m_controls.Add(d11);
            m_controls.Add(d12);
            m_controls.Add(d13);
            m_controls.Add(d14);

            for (int i = 0; i < m_controls.Count - 1; i++) {
                m_controls[i].JumpToNext = m_controls[i + 1];
            }

            foreach (var item in m_controls) {
                item.Clear();
            }
        }

        private List<DZXControl> m_controls = new List<DZXControl>();

        public DZXControl this[int index] { get { return m_controls[index]; } }

        public int Count {
            get {
                return m_controls.Count;
            }
        }

        public void ClearData() {
            for (int i = 0; i < Count; i++) {
                var item = m_controls[i];
                item.Clear();
            }
        }

        public void SetCC(List<int> cc) {
            var list = cc;
            var cl = new List<DZXControl>();
            for (int i = 0; i < this.Count; i++) {
                var item = this[i];
                var isOK = list.IndexOf(i) != -1;
                item.Enabled = isOK;
                if (isOK) cl.Add(item);
            }

            for (int i = 0; i < cl.Count; i++) {
                if (i < cl.Count - 1) {
                    cl[i].JumpToNext = cl[i + 1];
                }
            }
        }

    }
}
